{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print(\"猜数字进阶版之数字炸弹小游戏\")\n",
    "import random\n",
    "bomb=random.randint(0,1000)\n",
    "print(\"炸弹已设置\")\n",
    "min=\"0\"\n",
    "max=\"1000\"\n",
    "range=min+\"~\"+max+\"之间\"\n",
    "\n",
    "while True:\n",
    "        numb = input(\"请输入一个%s的数字：\" %range)\n",
    "        if numb.isdigit():\n",
    "            numb=int(numb)\n",
    "            if bomb == numb:\n",
    "                print(\"爆炸啦，接受惩罚吧！\")\n",
    "                break\n",
    "            elif numb > int(max) or numb < int(min):\n",
    "                print(\"输入的数字不符合范围，直接受罚吧！\")\n",
    "                break\n",
    "            elif numb > bomb:\n",
    "                numb=str(numb)\n",
    "                range=min+\"~\"+numb+\"之间\"\n",
    "                max=numb\n",
    "                print(\"恭喜你躲过一劫！\")\n",
    "            elif numb < bomb:\n",
    "                numb=str(numb)\n",
    "                range=numb+\"~\"+max+\"之间\"\n",
    "                min=numb\n",
    "                print(\"恭喜你躲过一劫！\")\n",
    "        else:\n",
    "            print(\"输入的东西不符合规定，直接受罚吧！\")\n",
    "            break"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
